import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JProgressBar;

public class Intro extends JFrame{

	private Thread t;
	private JProgressBar bar;
	private JButton launch ;
	
	public Intro(){
		
		this.setSize(300, 80);
		this.setTitle("Etablissement de Connexion ");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setLocationRelativeTo(null);
		
		
		t = new Thread(new Traitement());
		bar  = new JProgressBar();
		bar.setMaximum(300);
		bar .setMinimum(0);
		bar.setStringPainted(true);
		
		this.getContentPane().add(bar, BorderLayout.CENTER);
		
		launch = new JButton("Lancer");
		launch.addActionListener(new ActionListener(){
            @Override
			public void actionPerformed(ActionEvent event){
				dispose();
                                Acceuil ac= new Acceuil();
                                ac.setVisible(true);
				
			}
		});		
		this.getContentPane().add(launch, BorderLayout.SOUTH);		
		t.start();		
		this.setVisible(true);		
	}
	
	class Traitement implements Runnable{
	
		public void run(){
			launch.setEnabled(false);
			
			for(int val = 0; val <= 300; val++){
				bar.setValue(val);
				try {
					t.sleep(4);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			launch.setEnabled(true);
		}	
	}
	
	
	
}
